home *** CD-ROM | disk | FTP | other *** search
- /* ======================================================================
- DESC: Common Functions for the View Servers Operations
-
- PLATFORMS: >= MS IE 4.0
-
- USAGE NOTES:
- ====================================================================== */
- var ALupMode = ""; // Lookup Mode of Operation, Computer, Counter
- var ServicesArray = new Array("PING","HTTP","FTP","SMTP","POP","DNS","USER","SQL","SNMP","TELNET","ORACLE","L_NOTES","AGENT");
- var ServicesRecCount = 0; // Count of records returned from Services Lookup operation
- var AlertLupRecCount = 0; // Count of records returned from Alert Lookup operation
- var AlertSelectIdx = 0; // Index of currently selected Alert
-
- /* Initial Alert Lookup Request */
- var AlLookupBsy = false;
- function processAlLookup() {
- if ( AlLookupBsy ) // exit if already Busy
- return;
- if ( AL_AlertStoreArr.length > 0 )
- return; // exit if already exists
- AlLookupBsy = true; // set Busy
-
- AlertLupRecCount = 0; // clear Lookup record counter
- if ( RpmCC_VA.AlertGroupLookup("*") ) {
- ALupMode = "";
- AlLookupBsy = false; // free
- top.Rstatus.Pstat("Unable to start the Alert LOOKUP request",true);
- }
- else {
- ALupMode = "Lookup"; // set Mode of operation
- top.Rstatus.Pstat("One moment while Alert LOOKUP request completes");
- }
- }
-
- /* Process Alert LOOKUP RECORD Event */
- var AlertRecLength = 3; // Alert Lookup record length
- function AlertLupRec(AlID, AlName, AlDesc) {
- var i = AlertLupRecCount * AlertRecLength;
- AL_AlertStoreArr[i++] = AlName; //+0
- AL_AlertStoreArr[i++] = AlID;
- AL_AlertStoreArr[i] = AlDesc;
- ++AlertLupRecCount; // bump record received counter
- }
-
- /* Process DB Error in Alert Lookup Operation */
- function processAlertOpError() {
- AlLookupBsy = false; // free
- top.Rstatus.Pstat("An error occurred during Alert LOOKUP operation",true);
- }
- function processComputerOpError() {
- AlLookupBsy = false; // free
- top.Rstatus.Pstat("An error occurred during Computer LOOKUP operation",true);
- }
- /* Process Alert/Object OP Complete Event */
- function processAlertOpComplete() {
- top.Rstatus.Pstat("Request Completed");
- if (ALupMode == "Lookup") {
- // Do Services Lookup
- ServicesRecCount = 0; // reset count
- ALupMode = "ServicesLookup";
- rstat = RpmCC_VA.ServicesLookup("","","ComputerID,ID DESC");
- if ( rstat ) { // if unable to initiate request
- AlLookupBsy = false; // free
- top.Rstatus.Pstat("Unable to start the Services LOOKUP request",true);
- }
- else { // waiting for OperationCompleteEvent
- top.Rstatus.Pstat("One moment while Services LOOKUP request completes");
- }
- }
- }
-
- // Process Serverices LOOKUP Record Event
- var ServicesRecLength = 4; // Services Lookup record length
- function processServicesRecord(SRVstrg) {
- var warr = new Array();
- warr = SRVstrg.split("~");
- var j = ServicesRecCount * ServicesRecLength;
- AC_ServicesStoreArr[j] = warr[1]; // Computer ID
- AC_ServicesStoreArr[j+1] = warr[2]; // AlertGroup ID
- warr[3] = (warr[3] == "SQLCONNECT") ? "SQL" : warr[3];
- AC_ServicesStoreArr[j+2] = warr[3]; // Type
- AC_ServicesStoreArr[j+3] = warr[11]; // Disable Flag
- ++ServicesRecCount; // bump record counter
- }
-
- /* Process DB Error in Services Lookup Operation */
- function processServicesOpError() {
- AlLookupBsy = false; // free
- top.Rstatus.Pstat("An error occurred during Computer LOOKUP operation",true);
- }
- // Prcoess Services Operation Complete Event
- function processServicesOpComplete() {
- if (ALupMode == "ServicesLookup"){
- top.Rstatus.Pstat("Done");
- ALupMode = "";
- getComputerInfo(); // go start lookupfor Computer info
- processServiceTree(); // create Services tree
- AlLookupBsy = false; // free
- // If Filter should be validated,do it
- if ( ValidateFilter ) {
- ValidateFilter = false; // reset
- for ( var i=0,j=0; i<AC_FilterStoreArr.length; i+=FilterRecLength ) {
- VCid = AC_FilterStoreArr[i]; // Computer ID
- VStyp = AC_FilterStoreArr[i+1]; // Service Type
- if ( !IsActiveServiceWatch(VCid,VStyp) ) { // if not
- for (var j=i+FilterRecLength; j < AC_FilterStoreArr.length; ++i, ++j) {
- AC_FilterStoreArr[i] = AC_FilterStoreArr[j];
- }
- AC_FilterStoreArr.length -= FilterRecLength;
- i -= FilterRecLength; // adjust index to compensate for deleted entry
- }
- }
- // Update Filter save
- RpmCC_VA.RegSetKey(top.banner.ServerID+"ServerWatchFilterArray",AC_FilterStoreArr.join("~"));
- }
- }
- }
- // See if Specified Parameters are a Valid ServiceWatch
- function IsActiveServiceWatch(ACid,AStyp) {
- for ( var i=0,j=0;i<AC_ServicesStoreArr.length; i+=ServicesRecLength ) {
- // Match on Type and Computer ID Assigned to an Alert Group
- if ( AC_ServicesStoreArr[i+2] == AStyp && AC_ServicesStoreArr[i] == ACid ) {
- if ( AC_ServicesStoreArr[i+1] != 0 ) // if assigned an Alert
- return true;
- else
- return false;
- }
- }
- }
-
- // Process and Display the Services:Computer Tree
- var ServExpandedCount = 0;
- function processServiceTree() {
- AL_CCOneServ.innerHTML = ""; // clear display
- /* Format and Output Service tree list */
- setOutHeader("Service : Server/Computer Tree"); // define output table header
- ServExpandedCount = 0; // init
- for ( var i=0; i<ServicesArray.length; i++) {
- CCEs += "<table border='0' cellpadding='0' cellSpacing='0' width='450'><tr><td width='25'> </td>";
- Iprefx = ( i+1 >= ServicesArray.length ) ? "L" : "T";
- CCEs += "<td width='19' align='center'><img id='sima" + i + "' expanded='0' src='images/" + Iprefx + "plus.gif' style='cursor:hand' onclick='procSrvImgClick(this)' width='19' height='20'></td>";
- CCEs += "<td width='19' align='center'><img id='simb" + i + "' src='images/sAdminServers.gif' style='cursor:hand' onclick='procSrvImgClick(this)' width='16' height='16' title='";
- CCEs += "'></td><td width='*' class='optext'>" + ServicesArray[i] + "</td></tr></table>";
- CCEs += "<div id='sexp" + i + "' compcount='0'></div>";
- }
- AL_CCOneServ.insertAdjacentHTML("beforeEnd",CCEs);
- }
- /* Display Header for Service and Object:Counter Trees */
- function setOutHeader(Tstrg) {
- CCEs = "<table border='0' cellpadding='0' cellSpacing='0' width='450'>";
- CCEs += "<tr><td width='25'> </td>";
- CCEs += "<td width='19' height='20' align='center'><img src='images/topopen.gif' width='19' height='20'></td><td colspan='2' width='*' class='optextn'>" + Tstrg + "</td></tr></table>";
- }
-
- /* Process Click on Service in Service Tree */
- var CurExpServIx = null; // Index to Current Expanded Service
- var EObj = null; // expanded Service Object
- var CTparm = "optext";
- var warrsic = new Array();
- function procSrvImgClick(SIm) {
- isx = SIm.id;
- if ( isx.charAt(0) != "s" || ALupMode != "" ) { // if not a "simaxx"
- top.banner.beep();
- return;
- }
- var cx = isx.substring(4,isx.length); // Strip off index
-
- CurExpServIx = parseInt(cx,10);
- CObj = document.all["sima"+cx];
- EObj = document.all["sexp"+cx];
- Cpfx = (CurExpServIx+1 >= ServicesArray.length) ? "L" : "T";
-
- if ( CObj.expanded == "1" ) { // if currently expanded
- CObj.src = "images/" + Cpfx + "plus.gif";
- EObj.style.display = "none";
- EObj.innerHTML = ""; // Contract
- CObj.expanded = "0"; // Set contracted
- ServExpandedCount-=EObj.compcount; // decrement count of open computers
- }
- else { // otherwise Expand
- CObj.src = "images/" + Cpfx + "minus.gif";
- CObj.expanded = "1"; // Set expanded
-
- // find and list computers for expanded service
- CCEs = "";
- CurCmpIx = 0;
- var cName = ""; // Computer Name
- var SType = ServicesArray[CurExpServIx]; // Service Type
- for ( var i=0,j=0; i<AC_ServicesStoreArr.length; i+=ServicesRecLength ) {
- // Match on Type and Assigned to an Alert Group
- if ( AC_ServicesStoreArr[i+2] == SType && AC_ServicesStoreArr[i+1] != "0") {
- CTparm = ( AC_ServicesStoreArr[i+3] == "1" ) ? "optextr" : "optext";
- warrsic[j] = AC_ServicesStoreArr[i];
- ++j; // bump computer count
- }
- }
-
- ALupMode = ""; // reset mode
- ServExpandedCount+=j; // increment total number of computers opened
- EObj.compcount = j; // set number computers opened
- if ( (CmpsExpected = j) == 0 ) {
- top.Rstatus.Pstat("No Computers defined for "+ SType +" Service");
- }
- else {
- top.banner.processStartComm();
- top.Rstatus.Pstat("Moment Please");
- ETid = setTimeout("processEditSrvComputerContinue()",100); // Delay
- }
- }
- // enable SelectAll/UnselectAll buttons if computers opened
- if ( ServExpandedCount > 0 ) {
- SetButtonState(bSelC,"0");
- SetButtonState(bUselC,"0");
- }
- else { // otherwise disable the buttons
- SetButtonState(bSelC,"1");
- SetButtonState(bUselC,"1");
- }
- }
- function processEditSrvComputerContinue() {
- ETid = null;
- for ( var i=0; i<CmpsExpected; i++ ) {
- cName = getCompNameDesc(warrsic[i]); // get Computer Name & Desc
- processEditSrvComputer(cName,curCompDesc,warrsic[i]);
- }
- processEditSrvComputerComplete();
- }
-
- function SetButtonState(BtObj,BState) {
- //BtObj.className = (BState == "0") ? "BoxButton" : "BoxButtonD";
- BtObj.disabled = (BState == "0") ? "" : "disabled";
- }
- function processEditSrvComputer(CmpNme,CmpDesc,CID) {
- Opfx = (CurExpServIx+1 >= ServicesArray.length) ? "White" : "I";
- Mpfx = (CurCmpIx+1 == CmpsExpected) ? "L" : "T";
-
- CCEs += "<table border='0' cellpadding='0' cellSpacing='0' width='450'>";
- CCEs += "<tr><td width='25'> </td><td width='19' height='20' align='center'><img src='images/" + Opfx + ".gif' width='19' height='20'></td>";
- CCEs += "<td width='19' height='20' align='center'><img src='images/" + Mpfx + ".gif' width='19' height='20'></td>";
- CCEs += "<td width='11' align='center' style='backgroundColor:white'><img id='vima" + CurExpServIx + "_" + CurCmpIx;
-
- if ( CheckFilterStore(CID,ServicesArray[CurExpServIx]) && AC_FilterStoreArr.length != 0 ) {
- CCEs += "' checked='1' src='images/Checked.gif'";
- CmpImg = "sMicroscope.gif";
- }
- else {
- CCEs += "' checked='0' src='images/Unchecked.gif'";
- CmpImg = "Computer.gif";
- }
- var gn = getCurrentAlertGrpName(CID,ServicesArray[CurExpServIx]);
- if ( CTparm == "optextr" ) { // if suspended
- gn += " : SUSPENDED";
- }
- CCEs += " compid='" +CID+"' style='cursor:hand' onclick='procCmpImgClick(this)' width='9' height='9'></td>";
- CCEs += "<td width='19' align='center'><img id='pimb" + CurExpServIx + "_" + CurCmpIx + "' src='images/"+CmpImg+"' style='cursor:hand' onclick='procCmpImgClick(this)' width='15' height='16' title='Desc: ";
- CCEs += CmpDesc;
- if ( CmpDesc.length > 0 )
- CCEs += " ; ";
- CCEs += "Watch/Alert: "+gn+"'></td>";
- CCEs += "<td width='*' class='"+CTparm+"'>" + CmpNme + "</td>";
- CCEs += "</tr></table>";
- ++CurCmpIx; // bump index
- }
-
- function getCurrentAlertGrpName(CmpID,CSType) {
- for ( var i=0,j=0; i<AC_ServicesStoreArr.length; i+=ServicesRecLength ) {
- // Match on Type and Assigned to an Alert Group
- if ( AC_ServicesStoreArr[i+2] == CSType && AC_ServicesStoreArr[i] == CmpID ) {
- var gn = getOnlyAlertName(AC_ServicesStoreArr[i+1]); // get name based on Alert Group ID
- return gn;
- }
- }
- return "";
- }
-
- /* Read of Computers complete; Output formatted Computers */
- function processEditSrvComputerComplete() {
- EObj = document.all["sexp"+CurExpServIx];
- EObj.insertAdjacentHTML("beforeEnd",CCEs);
- EObj.style.display = "";
- EObj.compcount = CurCmpIx; // Count of Computers
- document.all["sima"+CurExpServIx].scrollIntoView(true);
- ALupMode = "";
- top.Rstatus.Pstat("Request Completed");
- top.banner.processStopCommX();
- }
-
- /* Process Click to Check or Uncheck a Computer */
- function procCmpImgClick(CmpIm) {
- isx = CmpIm.id;
- if ( isx.charAt(0) != "v") // if not a or "vimaxx_yy"
- return;
- var cx = isx.substring(4,isx.length); // Strip off index
- lx = cx.lastIndexOf("_"); // derive suffix to the Service DIV ID
- var dx = cx.substring(0,lx);
-
- var CObj = document.all["vima"+cx]; // Clicked Computer Entry
- var FObj = document.all["pimb"+cx];
- if ( CObj.checked == "1" ) { // if currently Checked, Uncheck
- FObj.src = "images/Computer.gif";
- CObj.src = "images/Unchecked.gif";
- CObj.checked = "0"; // Set Unchecked
- RemoveFromFilterStore(CObj.compid,ServicesArray[dx]);
- }
- else { // otherwise Check
- FObj.src = "images/sMicroscope.gif";
- CObj.src = "images/Checked.gif";
- CObj.checked = "1"; // Set Checked
- AddToFilterStore(CObj.compid,ServicesArray[dx]);
- }
- SpecificationsMade = true; // flag that a change has been made
- }
-
- // Process SelectALL or UnselectALL
- function processSelect(Pflg) {
- var CObj = null;
- // Check each Service item to see if expanded
- for ( var i=0; i<ServicesArray.length; i++ ) {
- if ( document.all["sima"+i].expanded == "1" ) {
- // if expanded
- CCnt = document.all["sexp"+i].compcount; // computer count
- for ( var j=0; j<CCnt; j++ ) {
- CObj = document.all["vima"+i+"_"+j]; // computer entry in tree
- CObj.checked = Pflg; // set for select/unselect
- procCmpImgClick(CObj); // go process
- }
- }
- }
- }
-
- /* Get only the Alert Name from Store based on Alert ID */
- function getOnlyAlertName(AgID) {
- var AlertName = "";
- for (i=0; i < AL_AlertStoreArr.length; i+=AlertRecLength) {
- if ( AL_AlertStoreArr[i+1] == AgID ) {
- AlertName = AL_AlertStoreArr[i];
- break;
- }
- }
- return AlertName;
- }
- // Read all Computers assigned to Alert Groups
- function getComputerInfo() {
- var GCIDArr = new Array();
- var prevCID = "";
- AC_CompStoreArr.length = 0; // clear computer store
- for ( var i=0,j=0; i<AC_ServicesStoreArr.length; i+=ServicesRecLength ) {
- // Match on Assigned to an Alert Group
- if ( AC_ServicesStoreArr[i+1] != "0" && AC_ServicesStoreArr[i] != prevCID ) {
- if ( GCIDArr != "" ) {
- GCIDArr += ",";
- }
- GCIDArr += AC_ServicesStoreArr[i]; // Add Computer ID
- prevCID = AC_ServicesStoreArr[i];
- ++j; // bump computer count
- }
- }
- ALupMode = ""; // reset mode
- if ( j > 0 ) { // if some computers assigned
- /* Lookup Computer Names and Descriptions */
- if ( RpmCC_VA.ComputerLookupByIDArray(GCIDArr) ) {
- top.Rstatus.Pstat("Unable to start the Computer LOOKUP request",true);
- }
- else {
- ALupMode = "InitComputerLookup"; // set Mode of operation
- top.Rstatus.Pstat("One moment while Computer LOOKUP request completes");
- }
- }
- else {
- WarningBox.style.display = "none";
- WarningBox1.style.display = "";
- top.Rstatus.Pstat("No status messages available",true);
- top.banner.processStopCommX();
- }
- }
-